{
  "properties" : { },
  "id" : "copy1744479197614d72536",
  "script" : null,
  "groupId" : "8f5281bc475f40c9b352658edf5fe46b",
  "name" : "获取流程定义的XML",
  "createTime" : null,
  "updateTime" : 1744479999579,
  "lock" : null,
  "createBy" : null,
  "updateBy" : "可辉",
  "path" : "definition.xml",
  "method" : "GET",
  "parameters" : [ {
    "name" : "processDefinitionId",
    "value" : "59543012-17be-11f0-96fb-f4b3016ece8b",
    "description" : null,
    "required" : true,
    "dataType" : "String",
    "type" : null,
    "defaultValue" : "",
    "validateType" : null,
    "error" : null,
    "expression" : null,
    "children" : null
  } ],
  "options" : [ ],
  "requestBody" : "",
  "headers" : [ ],
  "paths" : [ ],
  "responseBody" : "{\n    \"code\": 200,\n    \"msg\": \"success\",\n    \"data\": \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\\n<bpmn2:definitions xmlns=\\\"http://www.omg.org/spec/BPMN/20100524/MODEL\\\" xmlns:bpmn2=\\\"http://www.omg.org/spec/BPMN/20100524/MODEL\\\" xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" xmlns:xsd=\\\"http://www.w3.org/2001/XMLSchema\\\" xmlns:activiti=\\\"http://activiti.org/bpmn\\\" xmlns:bpmndi=\\\"http://www.omg.org/spec/BPMN/20100524/DI\\\" xmlns:omgdc=\\\"http://www.omg.org/spec/DD/20100524/DC\\\" xmlns:omgdi=\\\"http://www.omg.org/spec/DD/20100524/DI\\\" xmlns:dc=\\\"http://www.omg.org/spec/DD/20100524/DC\\\" xmlns:di=\\\"http://www.omg.org/spec/DD/20100524/DI\\\" typeLanguage=\\\"http://www.w3.org/2001/XMLSchema\\\" expressionLanguage=\\\"http://www.w3.org/1999/XPath\\\" targetNamespace=\\\"http://activiti.org/bpmn20\\\" id=\\\"Definitions_1\\\" xsi:schemaLocation=\\\"http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd\\\">\\n  <bpmn2:process id=\\\"userInformationFormProcess\\\" name=\\\"用户信息表单流程\\\" isExecutable=\\\"true\\\">\\n    <bpmn2:startEvent id=\\\"startEvent\\\" name=\\\"开始\\\">\\n      <bpmn2:outgoing>flow1</bpmn2:outgoing>\\n    </bpmn2:startEvent>\\n    <bpmn2:userTask id=\\\"userFormTask\\\" name=\\\"填写表单\\\" activiti:assignee=\\\"${reporter}\\\"></bpmn2:userTask>\\n    <bpmn2:exclusiveGateway id=\\\"decisionGate\\\" name=\\\"审批人决策\\\">\\n      <bpmn2:incoming>flow2</bpmn2:incoming>\\n      <bpmn2:outgoing>toBuzhangApproval</bpmn2:outgoing>\\n      <bpmn2:outgoing>toRootApproval</bpmn2:outgoing>\\n    </bpmn2:exclusiveGateway>\\n    <bpmn2:userTask id=\\\"buzhangApproval\\\" name=\\\"部长审批\\\" activiti:candidateGroups=\\\"buzhang\\\">\\n      <extensionElements>\\n        <activiti:formProperty id=\\\"approve\\\" name=\\\"是否批准\\\" type=\\\"boolean\\\" required=\\\"true\\\"></activiti:formProperty>\\n      </extensionElements>\\n    </bpmn2:userTask>\\n    <bpmn2:userTask id=\\\"rootApproval\\\" name=\\\"管理员审批\\\" activiti:candidateGroups=\\\"root\\\">\\n      <extensionElements>\\n        <activiti:formProperty id=\\\"approve\\\" name=\\\"是否批准\\\" type=\\\"boolean\\\" required=\\\"true\\\"></activiti:formProperty>\\n      </extensionElements>\\n    </bpmn2:userTask>\\n    <bpmn2:exclusiveGateway id=\\\"approvalMerge\\\" name=\\\"合并审批结果\\\">\\n      <bpmn2:incoming>fromBuzhangToMerge</bpmn2:incoming>\\n      <bpmn2:incoming>fromRootToMerge</bpmn2:incoming>\\n      <bpmn2:outgoing>approved</bpmn2:outgoing>\\n      <bpmn2:outgoing>rejected</bpmn2:outgoing>\\n    </bpmn2:exclusiveGateway>\\n    <bpmn2:serviceTask id=\\\"addPoints\\\" name=\\\"增加积分\\\" activiti:class=\\\"com.example.AddPointsDelegate\\\">\\n      <extensionElements>\\n        <activiti:field name=\\\"userId\\\">\\n          <activiti:expression><![CDATA[${initiator}]]></activiti:expression>\\n        </activiti:field>\\n      </extensionElements>\\n    </bpmn2:serviceTask>\\n    <bpmn2:endEvent id=\\\"endEvent\\\" name=\\\"结束\\\">\\n      <bpmn2:incoming>rejected</bpmn2:incoming>\\n      <bpmn2:incoming>afterAddPointsToEnd</bpmn2:incoming>\\n    </bpmn2:endEvent>\\n    <bpmn2:sequenceFlow id=\\\"flow1\\\" sourceRef=\\\"startEvent\\\" targetRef=\\\"userFormTask\\\"></bpmn2:sequenceFlow>\\n    <bpmn2:sequenceFlow id=\\\"flow2\\\" sourceRef=\\\"userFormTask\\\" targetRef=\\\"decisionGate\\\"></bpmn2:sequenceFlow>\\n    <bpmn2:sequenceFlow id=\\\"toBuzhangApproval\\\" sourceRef=\\\"decisionGate\\\" targetRef=\\\"buzhangApproval\\\">\\n      <conditionExpression xsi:type=\\\"tFormalExpression\\\"><![CDATA[${role == 'buzhang'}]]></conditionExpression>\\n    </bpmn2:sequenceFlow>\\n    <bpmn2:sequenceFlow id=\\\"toRootApproval\\\" sourceRef=\\\"decisionGate\\\" targetRef=\\\"rootApproval\\\">\\n      <conditionExpression xsi:type=\\\"tFormalExpression\\\"><![CDATA[${role == 'root'}]]></conditionExpression>\\n    </bpmn2:sequenceFlow>\\n    <bpmn2:sequenceFlow id=\\\"fromBuzhangToMerge\\\" sourceRef=\\\"buzhangApproval\\\" targetRef=\\\"approvalMerge\\\"></bpmn2:sequenceFlow>\\n    <bpmn2:sequenceFlow id=\\\"fromRootToMerge\\\" sourceRef=\\\"rootApproval\\\" targetRef=\\\"approvalMerge\\\"></bpmn2:sequenceFlow>\\n    <bpmn2:sequenceFlow id=\\\"approved\\\" sourceRef=\\\"approvalMerge\\\" targetRef=\\\"addPoints\\\">\\n      <conditionExpression xsi:type=\\\"tFormalExpression\\\"><![CDATA[${approved == true}]]></conditionExpression>\\n    </bpmn2:sequenceFlow>\\n    <bpmn2:sequenceFlow id=\\\"rejected\\\" sourceRef=\\\"approvalMerge\\\" targetRef=\\\"endEvent\\\">\\n      <conditionExpression xsi:type=\\\"tFormalExpression\\\"><![CDATA[${approved == false}]]></conditionExpression>\\n    </bpmn2:sequenceFlow>\\n    <bpmn2:sequenceFlow id=\\\"afterAddPointsToEnd\\\" sourceRef=\\\"addPoints\\\" targetRef=\\\"endEvent\\\"></bpmn2:sequenceFlow>\\n  </bpmn2:process>\\n  <bpmndi:BPMNDiagram id=\\\"BPMNDiagram_userInformationFormProcess\\\">\\n    <bpmndi:BPMNPlane bpmnElement=\\\"userInformationFormProcess\\\" id=\\\"BPMNPlane_userInformationFormProcess\\\">\\n      <bpmndi:BPMNShape bpmnElement=\\\"startEvent\\\" id=\\\"BPMNShape_startEvent\\\">\\n        <omgdc:Bounds height=\\\"36.0\\\" width=\\\"36.0\\\" x=\\\"50.0\\\" y=\\\"120.0\\\"></omgdc:Bounds>\\n      </bpmndi:BPMNShape>\\n      <bpmndi:BPMNShape bpmnElement=\\\"userFormTask\\\" id=\\\"BPMNShape_userFormTask\\\">\\n        <omgdc:Bounds height=\\\"80.0\\\" width=\\\"100.0\\\" x=\\\"150.0\\\" y=\\\"108.0\\\"></omgdc:Bounds>\\n      </bpmndi:BPMNShape>\\n      <bpmndi:BPMNShape bpmnElement=\\\"decisionGate\\\" id=\\\"BPMNShape_decisionGate\\\">\\n        <omgdc:Bounds height=\\\"40.0\\\" width=\\\"40.0\\\" x=\\\"300.0\\\" y=\\\"118.0\\\"></omgdc:Bounds>\\n      </bpmndi:BPMNShape>\\n      <bpmndi:BPMNShape bpmnElement=\\\"buzhangApproval\\\" id=\\\"BPMNShape_buzhangApproval\\\">\\n        <omgdc:Bounds height=\\\"80.0\\\" width=\\\"100.0\\\" x=\\\"400.0\\\" y=\\\"108.0\\\"></omgdc:Bounds>\\n      </bpmndi:BPMNShape>\\n      <bpmndi:BPMNShape bpmnElement=\\\"rootApproval\\\" id=\\\"BPMNShape_rootApproval\\\">\\n        <omgdc:Bounds height=\\\"80.0\\\" width=\\\"100.0\\\" x=\\\"400.0\\\" y=\\\"220.0\\\"></omgdc:Bounds>\\n      </bpmndi:BPMNShape>\\n      <bpmndi:BPMNShape bpmnElement=\\\"approvalMerge\\\" id=\\\"BPMNShape_approvalMerge\\\">\\n        <omgdc:Bounds height=\\\"40.0\\\" width=\\\"40.0\\\" x=\\\"550.0\\\" y=\\\"168.0\\\"></omgdc:Bounds>\\n      </bpmndi:BPMNShape>\\n      <bpmndi:BPMNShape bpmnElement=\\\"addPoints\\\" id=\\\"BPMNShape_addPoints\\\">\\n        <omgdc:Bounds height=\\\"80.0\\\" width=\\\"100.0\\\" x=\\\"650.0\\\" y=\\\"158.0\\\"></omgdc:Bounds>\\n      </bpmndi:BPMNShape>\\n      <bpmndi:BPMNShape bpmnElement=\\\"endEvent\\\" id=\\\"BPMNShape_endEvent\\\">\\n        <omgdc:Bounds height=\\\"36.0\\\" width=\\\"36.0\\\" x=\\\"682.0\\\" y=\\\"22.0\\\"></omgdc:Bounds>\\n      </bpmndi:BPMNShape>\\n      <bpmndi:BPMNEdge bpmnElement=\\\"afterAddPointsToEnd\\\" id=\\\"BPMNEdge_afterAddPointsToEnd\\\">\\n        <omgdi:waypoint x=\\\"700.0\\\" y=\\\"158.0\\\"></omgdi:waypoint>\\n        <omgdi:waypoint x=\\\"700.0\\\" y=\\\"58.0\\\"></omgdi:waypoint>\\n      </bpmndi:BPMNEdge>\\n      <bpmndi:BPMNEdge bpmnElement=\\\"rejected\\\" id=\\\"BPMNEdge_rejected\\\">\\n        <omgdi:waypoint x=\\\"570.0\\\" y=\\\"168.0\\\"></omgdi:waypoint>\\n        <omgdi:waypoint x=\\\"570.0\\\" y=\\\"0.0\\\"></omgdi:waypoint>\\n        <omgdi:waypoint x=\\\"700.0\\\" y=\\\"0.0\\\"></omgdi:waypoint>\\n        <omgdi:waypoint x=\\\"700.0\\\" y=\\\"22.0\\\"></omgdi:waypoint>\\n      </bpmndi:BPMNEdge>\\n      <bpmndi:BPMNEdge bpmnElement=\\\"approved\\\" id=\\\"BPMNEdge_approved\\\">\\n        <omgdi:waypoint x=\\\"589.0\\\" y=\\\"189.0\\\"></omgdi:waypoint>\\n        <omgdi:waypoint x=\\\"650.0\\\" y=\\\"194.0\\\"></omgdi:waypoint>\\n      </bpmndi:BPMNEdge>\\n      <bpmndi:BPMNEdge bpmnElement=\\\"fromRootToMerge\\\" id=\\\"BPMNEdge_fromRootToMerge\\\">\\n        <omgdi:waypoint x=\\\"500.0\\\" y=\\\"230.0\\\"></omgdi:waypoint>\\n        <omgdi:waypoint x=\\\"558.0\\\" y=\\\"196.0\\\"></omgdi:waypoint>\\n      </bpmndi:BPMNEdge>\\n      <bpmndi:BPMNEdge bpmnElement=\\\"fromBuzhangToMerge\\\" id=\\\"BPMNEdge_fromBuzhangToMerge\\\">\\n        <omgdi:waypoint x=\\\"500.0\\\" y=\\\"165.0\\\"></omgdi:waypoint>\\n        <omgdi:waypoint x=\\\"555.0\\\" y=\\\"183.0\\\"></omgdi:waypoint>\\n      </bpmndi:BPMNEdge>\\n      <bpmndi:BPMNEdge bpmnElement=\\\"toRootApproval\\\" id=\\\"BPMNEdge_toRootApproval\\\">\\n        <omgdi:waypoint x=\\\"330.0\\\" y=\\\"148.0\\\"></omgdi:waypoint>\\n        <omgdi:waypoint x=\\\"407.0\\\" y=\\\"220.0\\\"></omgdi:waypoint>\\n      </bpmndi:BPMNEdge>\\n      <bpmndi:BPMNEdge bpmnElement=\\\"toBuzhangApproval\\\" id=\\\"BPMNEdge_toBuzhangApproval\\\">\\n        <omgdi:waypoint x=\\\"339.0\\\" y=\\\"139.0\\\"></omgdi:waypoint>\\n        <omgdi:waypoint x=\\\"400.0\\\" y=\\\"144.0\\\"></omgdi:waypoint>\\n      </bpmndi:BPMNEdge>\\n      <bpmndi:BPMNEdge bpmnElement=\\\"flow2\\\" id=\\\"BPMNEdge_flow2\\\">\\n        <omgdi:waypoint x=\\\"250.0\\\" y=\\\"144.0\\\"></omgdi:waypoint>\\n        <omgdi:waypoint x=\\\"302.0\\\" y=\\\"140.0\\\"></omgdi:waypoint>\\n      </bpmndi:BPMNEdge>\\n      <bpmndi:BPMNEdge bpmnElement=\\\"flow1\\\" id=\\\"BPMNEdge_flow1\\\">\\n        <omgdi:waypoint x=\\\"86.0\\\" y=\\\"139.0\\\"></omgdi:waypoint>\\n        <omgdi:waypoint x=\\\"150.0\\\" y=\\\"144.0\\\"></omgdi:waypoint>\\n      </bpmndi:BPMNEdge>\\n    </bpmndi:BPMNPlane>\\n  </bpmndi:BPMNDiagram>\\n</bpmn2:definitions>\"\n}",
  "description" : null,
  "requestBodyDefinition" : null,
  "responseBodyDefinition" : null
}
================================
import 'org.activiti.engine.RepositoryService' as repositoryService;
import org.activiti.image.impl.DefaultProcessDiagramGenerator;
import org.activiti.bpmn.model.BpmnModel;
import org.activiti.bpmn.converter.BpmnXMLConverter;
import org.apache.commons.io.IOUtils;

import java.nio.charset.StandardCharsets;
import java.io.InputStream;
import response;

    // 根据流程定义ID获取BPMN模型
    BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId);

    BpmnXMLConverter converter = new BpmnXMLConverter()
    //把bpmnModel对象转换成字符
    String xmlContenxt = new String(converter.convertToXML(bpmnModel), StandardCharsets.UTF_8);

return response.download(xmlContenxt, processDefinitionId+'.xml');